/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package vmwapplication;

import java.awt.Font;
import java.awt.event.ComponentEvent;
import java.awt.event.ComponentListener;
import java.util.List;
import javax.swing.JDialog;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import vmwapplication.parser.solver.Result;

/**
 *
 * @author marek
 */
public class VMWDisplayAligment extends JDialog {
    
    public VMWDisplayAligment(java.awt.Frame parent){
        super(parent);
        initComponents();
        
    }
    
    private void initComponents(){
        
        textArea = new JTextArea();
        textArea.setColumns(100);
        textArea.setSize(1000, 770);
        Font font = new Font(Font.MONOSPACED, Font.PLAIN, 14);
        textArea.setFont(font);
        textArea.setEditable(false);
        
        pane = new JScrollPane(textArea);
        pane.setSize(990, 870);
        setLayout(null);
        add(pane);
        this.addComponentListener(new ComponentListener() {

            public void componentResized(ComponentEvent e) {
               Integer height = e.getComponent().getHeight() - 50;
               Integer width =e.getComponent().getWidth() - 50;
               pane.setSize(width, height);
               pane.updateUI();
            }

            public void componentMoved(ComponentEvent e) {
               
            }

            public void componentShown(ComponentEvent e) {
                
            }

            public void componentHidden(ComponentEvent e) {
                
            }
    
    });
        
        pack();
    }
    
    
    
    public void displayAligment(List<Result> results){
        StringBuffer sb= new StringBuffer();
        int max = 0;
        int l = 1;
        textArea.setText("");
        if(!results.isEmpty()){
            for(Result result : results){
                result.getAligmentA();
                result.getAligmentB();
                sb.append(l+") \n"); l++;
                sb.append(result.getAligmentA()+"\n");
                sb.append(result.getSlashes()+"\n");
                sb.append(result.getAligmentB()+"\n");
                sb.append("\n\n");
            }
            textArea.setRows(results.size() * 5);
            textArea.setColumns(max);
        }else{
            sb.append("Nebyly nalezene zadne podobne dna sekence.");
            textArea.setRows(5);
        }
        textArea.setText(sb.toString());
        textArea.updateUI();
        pane.updateUI();
    }
    
    JTextArea textArea;
    JScrollPane pane;
}
